import React from 'react'
import styled from 'styled-components'
import { cardStyles } from './ReusableStyles'
import { AreaChart, Area, Tooltip, ResponsiveContainer } from 'recharts'

const data = [
  { data: 4500 },
  {
    data: 5000,
  },
  {
    data: 4700,
  },
  {
    data: 4400,
  },
  {
    data: 4800,
  },
  {
    data: 5300,
  },
  {
    data: 5800,
  },
  {
    data: 6000,
  },
  {
    data: 6300,
  },
  {
    data: 6580,
  },
  {
    data: 6780,
  },
  {
    data: 6680,
  },
  {
    data: 6500,
  },
  {
    data: 6300,
  },
  {
    data: 5900,
  },
  {
    data: 5700,
  },
  {
    data: 5500,
  },
  {
    data: 5300,
  },
  {
    data: 5100,
  },
  {
    data: 5090,
  },
  {
    data: 5300,
  },
  {
    data: 5800,
  },
  {
    data: 6000,
  },
  {
    data: 6300,
  },
  {
    data: 6780,
  },
  {
    data: 6500,
  },
  {
    data: 6300,
  },
  {
    data: 6500,
  },
  {
    data: 6700,
  },
  {
    data: 7000,
  },
  {
    data: 7300,
  },
  {
    data: 7500,
  },
  {
    data: 7700,
  },
  {
    data: 8090,
  },
  {
    data: 8190,
  },
  {
    data: 7990,
  },

  {
    data: 7700,
  },
  {
    data: 7500,
  },
  {
    data: 7300,
  },
  {
    data: 7000,
  },
  {
    data: 6700,
  },
  {
    data: 6500,
  },
  {
    data: 6300,
  },
  {
    data: 6500,
  },
  {
    data: 6780,
  },
  {
    data: 6300,
  },
  {
    data: 6000,
  },
  {
    data: 5800,
  },

  {
    data: 5490,
  },
  {
    data: 6000,
  },
  {
    data: 8000,
  },
]

export default function Earnings() {
  return (
    <Section>
      <div className='top'>
        <h5>本月收入</h5>
        <h1>￥9246.32</h1>
        <div className='growth'>
          <span>+5.38%</span>
        </div>
      </div>
      <div className='chart'>
        <ResponsiveContainer width='100%' height='100%'>
          <AreaChart
            width={500}
            height={400}
            data={data}
            margin={{ top: 0, left: 0, right: 0, bottom: 0 }}
          >
            <Tooltip cursor={false} />
            <Area
              animationBegin={800}
              animationDuration={2000}
              type='monotone'
              dataKey='data'
              stroke='#ffc107'
              fill='#8068233e'
              strokeWidth={4}
              isAnimationActive={true}
            />
          </AreaChart>
        </ResponsiveContainer>
      </div>
    </Section>
  )
}

const Section = styled.section`
  ${cardStyles}
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 20rem;
  padding: 1.5rem 0 0 0;
  .top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    h1 {
      font-size: 2rem;
    }
    .growth {
      background-color: #d7e4121d;
      padding: 0.5rem;
      border-radius: 1rem;
      color: #ffc107;
      transition: all 0.4s ease-in-out;
      :hover {
        background-color: #ffc107;
        span {
          color: #000;
        }
      }
    }
  }
  .chart {
    height: 72%;
    width: 100%;
    .recharts-default-tooltip {
      background-color: black !important;
      border-color: black !important;
      border-radius: 0.6rem;
    }
  }
`
